package com.ljm.boot.controller;


import com.ljm.boot.domain.UserEntity;
import com.ljm.boot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Date;
import java.util.List;

@RestController()
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping(value = "/getUser")
    @ResponseBody
    public String getUserName(String UserName){
        UserEntity userEntity = new UserEntity("2", "throb", "男", 30, "江西吉安遂川", "13197577976", new Date());
        List<UserEntity>  userList = userService.getUser(userEntity);
        return userList==null?"":userList.get(0).getUserName();
    }

    @RequestMapping(value = "/saveUser")
    public String setUserName() throws IOException {
        UserEntity userEntity = new UserEntity("2", "throb", "男", 30, "江西吉安遂川", "13197577976", new Date());
        userService.saveUser(userEntity);
        return "1";
    }
}
